package top.yzlin.jqueryjx3strategystation.entity.user;

import com.alibaba.fastjson.annotation.JSONField;
import lombok.Data;

import javax.persistence.*;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.Pattern;

@Entity
@Table(name = "user_table")
@Data
public class User {
    public static final String ORDINARY="ordinary";
    public static final String ADMIN="admin";
    public static final String BAND="band";

    @NotBlank
    @Pattern(regexp="^[a-zA-Z]\\w{4,16}$")
    private String userName;

    @NotBlank
    @Pattern(regexp="^[\\u4e00-\\u9fa5a-zA-Z0-9]{2,12}$")
    private String nickName;

    @Id
    @GeneratedValue(strategy = GenerationType.TABLE, generator = "HIBERNATE_SEQUENCES")
    @TableGenerator(name = "HIBERNATE_SEQUENCES", pkColumnValue = "user_key", allocationSize = 1)
    private Integer userId;

    @NotBlank
    @Pattern(regexp="^\\w{4,10}$")
    @JSONField(serialize = false)
    private String password;
    private String portrait;
    private String permissions;
}
